<?php

namespace app\agent\controller;

use think\facade\Db;

use app\agent\model\BalanceWarningConfig as BalanceWarningConfigModel;
use app\agent\validate\BalanceWarningConfig as BalanceWarningConfigValidate;

/**
 * 余额预警配置
 */
class BalanceWarningConfig extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 获取系统配置
     */
    public function get()
    {
        $model = new BalanceWarningConfigModel;
        return $model->get($this->agent['id']);
    }

    /**
     * 配置配置
     */
    public function set()
    {
        $data = input('post.');
        $validate = new BalanceWarningConfigValidate;
        if (!$validate->scene('set')->check($data)) {
            return fail($validate->getError());
        }

        $model = new BalanceWarningConfigModel;
        $data['agent_id'] = $this->agent['id'];
        return $model->set($data);
    }
}
